package com.vastcom.sigma.admin.conf;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {
    @Bean("dataSource")
    public DataSource dataSource(Environment env){
        HikariDataSource ds=new HikariDataSource();
        ds.setJdbcUrl(env.getProperty("spring.datasource.url"));
        ds.setUsername(env.getProperty("spring.datasource.username"));
        ds.setPassword(env.getProperty("spring.datasource.password"));
        ds.setDriverClassName(env.getProperty("spring.datasource.driver-class-name"));
//            ds.setIdleTimeout(60000);
//            ds.setConnectionTimeout(60000);
//            ds.setValidationTimeout(3000);
//            ds.setLoginTimeout(5);
//            ds.setMaxLifetime(60000);
//            ds.setMaximumPoolSize(100);

        return ds;

    }
}
